package com.leostadyn.stackfarm.timestatistics.presenter.admin;

import com.leostadyn.stackfarm.timestatistics.model.bean.ProjectBean;
import com.leostadyn.stackfarm.timestatistics.model.mentity.admin.ProjectManageModel;
import com.leostadyn.stackfarm.timestatistics.model.minterface.admin.IProjectManageModel;
import com.leostadyn.stackfarm.timestatistics.presenter.BasePresenter;
import com.leostadyn.stackfarm.timestatistics.view.vinterface.admin.IProjectManageView;

import java.util.ArrayList;
import java.util.HashMap;

import io.reactivex.disposables.CompositeDisposable;


public class ProjectManagePresenter extends BasePresenter<IProjectManageView> {

    public void refresh(CompositeDisposable compositeDisposable, HashMap<String, String> map) {

        if (!isViewAttached()) {
            return;
        }
        mView = getView();
        mView.showWaiting();

        ProjectManageModel.refresh(map, compositeDisposable, new IProjectManageModel() {
            @Override
            public void successProject(ArrayList<ProjectBean> projectBeanArrayList) {
                mView.successProjectMessage(projectBeanArrayList);

            }

            @Override
            public void addProject() {

            }

            @Override
            public void onCompleted() {
                mView.dismissWaiting();
            }

            @Override
            public void onFailure() {

            }

            @Override
            public void onSuccess() {

            }

            @Override
            public void noInternet() {

            }

        });

    }

    //删除操作
    public void delete(CompositeDisposable compositeDisposable, HashMap<String, String> map) {
        if (!isViewAttached()) {
            return;
        }
        mView = getView();
        mView.showWaiting();

        ProjectManageModel.addProject(map, compositeDisposable, new IProjectManageModel() {
            @Override
            public void successProject(ArrayList<ProjectBean> projectBeanArrayList) {

            }

            @Override
            public void addProject() {

            }

            @Override
            public void onCompleted() {
                mView.dismissWaiting();
            }

            @Override
            public void onFailure() {
                mView.showWaiting();
            }

            @Override
            public void onSuccess() {

            }

            @Override
            public void noInternet() {

            }

        });

    }

    public void addProject(CompositeDisposable compositeDisposable, HashMap<String, String> map) {

        if (!isViewAttached()) {
            return;
        }
        mView = getView();
        mView.showWaiting();

        ProjectManageModel.addProject(map, compositeDisposable, new IProjectManageModel() {
            @Override
            public void successProject(ArrayList<ProjectBean> projectBeanArrayList) {
                mView.successProjectMessage(projectBeanArrayList);

            }

            @Override
            public void addProject() {

            }

            @Override
            public void onCompleted() {

            }

            @Override
            public void onFailure() {

            }

            @Override
            public void onSuccess() {
                mView.dismissWaiting();
            }

            @Override
            public void noInternet() {

            }

        });
    }

    //删除操作
    public void update(CompositeDisposable compositeDisposable, HashMap<String, String> map) {
        if (!isViewAttached()) {
            return;
        }
        mView = getView();
        mView.showWaiting();

        ProjectManageModel.updateProject(map, compositeDisposable, new IProjectManageModel() {
            @Override
            public void successProject(ArrayList<ProjectBean> projectBeanArrayList) {

            }

            @Override
            public void addProject() {

            }

            @Override
            public void onCompleted() {
                mView.dismissWaiting();
            }

            @Override
            public void onFailure() {
                mView.showWaiting();
            }

            @Override
            public void onSuccess() {

            }

            @Override
            public void noInternet() {

            }

        });

    }


}
